%function r=stateEntropyRate(mc);%calculates the entropy rate (bits/transition)%of a single stationary ergodic MarkovChain %%Input:%mc=    single MarkovChain object%%Result:%r=     H(S(t)|S(t-1))%%Arne Leijon 2009-07-19 testedfunction r=stateEntropyRate(mc)if finiteDuration(mc)	error('Finite duration: cannot estimate average state entropy rate');end;%*****Can the calculation be extended to finite-duration HMMs???Afix=max(mc.TransitionProb,realmin);%to avoid log(0)r=-mc.InitialProb'*sum(mc.TransitionProb.*log2(Afix),2);